#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> val(n+1), nxt(n + 1), pre(n + 1);
  for (int i = 1; i <= n; i ++) {
    val[i] = i;
    nxt[i] = i + 1;
    pre[i] = i - 1;
  }
  pre[1] = n;
  nxt[n] = 1;
  int cur = 1;
  while (n --) {
    // 1. 走 m - 1
    for (int i = 1; i <= m - 1; i ++) {
      cur = nxt[cur];
    }
    // 2. remove
    int next = nxt[cur], prev = pre[cur];
    nxt[prev] = next;
    pre[next] = prev;
    cout << cur << ' ';
    // 3. 走一步
    cur = nxt[cur];
  }
  cout << endl;
}